<!DOCTYPE html>
<html>
<head>
  <meta name="viewport"
        content="width=device-width, initial-scale=1, user-scalable=no, minimal-ui"/>
  <meta name="apple-mobile-web-app-capable" content="yes"/>
  <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
  <meta name="format-detection" content="telephone=no, email=no"/>
  <meta charset="UTF-8">
  <title>萌宝</title>
  <link rel="stylesheet" href="${request.contextPath}/static/front/themes/css/core.css">
  <link rel="stylesheet" href="${request.contextPath}/static/front/themes/css/icon.css">
  <link rel="stylesheet" href="${request.contextPath}/static/front/themes/css/home.css">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link href="iTunesArtwork@2x.png" sizes="114x114" rel="apple-touch-icon-precomposed">
</head>
<body>
<div id="prod">
  <input type="hidden" id="isLogin" value="${isLogin!''}">
  <input type="hidden" id="message" value="${message!''}">
  <input type="hidden" id="keyword" value="${keyword!''}" />
  <input type="hidden" id="classifyId" value="${classifyId!''}" />
<#include "common/header-nav.ftl">
  <section class="aui-new-search-content">
    <div class="aui-new-search-tab">
      <ul>
        <li>
          <span class="aui-active">综合</span>
        </li>
        <li>
          <span>销量</span>
        </li>
        <li>
          <span>价格</span>
        </li>
        <li>
          <span>筛选</span>
        </li>
      </ul>
    </div>
    <div class="aui-custom-search-tab">
      <ul>
        <li>
          <span class="aui-active">萌宝配送</span>
        </li>
        <li>
          <span>新品</span>
        </li>
        <li>
          <span>品牌</span>
        </li>
        <li>
          <span>前置摄像</span>
        </li>
      </ul>
    </div>
  </section>
  <section class="aui-list-product">
    <div class="aui-list-product-float-item" id="prodList">

    </div>
  </section>
</div>
<script src="${request.contextPath}/static/front/themes/js/jquery.min.js"></script>
<script src="${request.contextPath}/static/common/common.js?v=${staticVersion}"></script>
<script type="text/javascript">
  $(document).ready(function () {
     var classifyId = $("#classifyId").val();
     var keyword = $("#keyword").val();
     loadProd(classifyId,keyword);
  });

  function loadProd(classifyId,keyword){
    var url = '${request.contextPath}/product/getProdList';
    var data = {
      classifyId: classifyId,
      keyword: keyword
    };
    var result = ajaxPost(url,data);
    if(result != null && null != result.data){
      var childHtml = '';
      var prodList = result.data.prodList;
      if(null != prodList && prodList.length>0) {
        for (var i = 0; i < prodList.length; i++) {
          var prodImg = prodList[i].prodImg;
          var prodName = prodList[i].prodName;
          var prodUnit = prodList[i].prodUnit;
          var price = prodList[i].price;
          var disPrice = prodList[i].disPrice;
          var prodId = prodList[i].prodId;
          var title = prodName+'/'+prodUnit+'【质量在的心中，名牌在的手中，责任在的肩上，诚信在的言行中】';
          childHtml += '<a href="javascript:;" class="aui-list-product-fl-item">';
          childHtml += '<div class="aui-list-product-fl-img">';
          childHtml += '<img src="${request.contextPath}'+prodImg+'" alt="">';
          childHtml += '</div>';
          childHtml += '<div class="aui-list-product-fl-text">';
          childHtml += '<h3 class="aui-list-product-fl-title">'+title+'</h3>';
          childHtml += '<div class="aui-list-product-fl-mes">';
          childHtml += '<div>';
          childHtml += '<span class="aui-list-product-item-price"><em>¥</em>'+price+'</span>';
          childHtml += '<span class="aui-list-product-item-del-price">¥'+disPrice+'</span>';
          childHtml += '</div>';
          childHtml += '<div class="aui-btn-purchase">99%好评</div>';
          childHtml += '<div style="color:red" onclick="addCar('+prodId+',1,true)">加购物车</div>';
          childHtml += ' </div>';
          childHtml += '<div class="aui-list-self-sell">';
          childHtml += '<span class="aui-self-sell">自营</span>';
          childHtml += '<em class="aui-self-sell-em">247800条评价</em>';
          childHtml += '</div></div>';
          childHtml += '</a>';
        }
      }
      $("#prodList").html(childHtml);
    }
  }

  function addCar(prodId,num) {
    var isLogin = $("#isLogin").val();
    if(isLogin != null && isLogin =="1"){
      addToCar(prodId,num,true);
    }else{
      var message = $("#message").val();
      alert(message);
      top.location.href = '${request.contextPath}/user/login';
      return false;
    }
  }
</script>
</body>
</html>